import 'package:flutter/material.dart';
import 'package:untitled/utils/SnackBarHepler.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      scaffoldMessengerKey: ScaffoldMessengerGlobalKey,
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  double selectValue = 1.0;
  @override
  Widget build(BuildContext context) {
    //脚手架
    return Scaffold(
      appBar: AppBar(
        title: Text('滑块'),
        backgroundColor: Colors.blue,
        foregroundColor: Colors.white,
      ),

      body: SizedBox.expand(
        child: Column(
          children: [
            SliderTheme(
              data: SliderTheme.of(context).copyWith(
                //轨道的高度
                trackHeight: 20,
                //轨道的形状
                //RoundedRectSliderTrackShape  默认的圆角矩形
                //RectangularSliderTrackShape 矩形
                trackShape: RectangularSliderTrackShape(),
                //拇指的样式  RoundSliderThumbShape
                thumbShape: RoundSliderThumbShape(),
              ),
              child: Slider(
                value: selectValue,
                //最小值
                min: 1,
                //最大值
                max: 100,
                // divisions: 4,
                //divisions 不为null的时候 拖动时 显示在值指示器中的文本
                label: "测试Label",
                //次级轨道的颜色
                secondaryActiveColor: Colors.red,
                //次级轨道的值
                secondaryTrackValue: 80,
                padding: EdgeInsets.only(top: 40, left: 20, right: 20),
                //滑块有效部分的颜色
                activeColor: Colors.green,
                //滑块无效部分的颜色
                inactiveColor: Colors.blueGrey,
                //拇指的颜色
                thumbColor: Colors.yellow,
                //拖动 按下时高亮颜色
                // overlayColor: WidgetStateProperty.all(Colors.black),
                //滑动中
                onChanged: (double value) {
                  setState(() {
                    selectValue = value;
                  });
                  print(' selectValue $selectValue ');
                },
                //滑动开始
                onChangeStart: (double startValue) {
                  print('Started change at $startValue');
                },
                //滑动结束
                onChangeEnd: (double endVarlu) {
                  print('End change at $endVarlu');
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
